package com.huabo.contract.mysql.mapper;

import com.hbfk.util.PageInfo;
import com.huabo.contract.mysql.entity.TblCyhwUnitMySql;
import com.huabo.contract.mysql.entity.TblLegalArbitratsettlementMySql;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author huabo
 * @since 2022-03-21
 */
public interface TblLegalArbitratsettlementMySqlMapper extends BaseMapper<TblLegalArbitratsettlementMySql> {

    @Select("SELECT * FROM TBL_LEGAL_ARBITRATSETTLEMENT TLA\n" +
            "LEFT JOIN TBL_LEGAL_NEGOTIATEDSETTLEMEN TLN ON TLA.NEGOTIATEINFO = TLN.NEGOTIAID\n" +
            "LEFT JOIN TBL_LEGAL_DISPUTREGISTRATION TLD ON TLN.DISPUINFO = TLD.DISPUTEID" +
            " WHERE ARBITRAID = #{arbitraId}")
    @Options(useGeneratedKeys=true, keyProperty="arbitraid", keyColumn="ARBITRAID")
    TblLegalArbitratsettlementMySql findByArbitraId(Integer arbitraId);

    @Select("SELECT TCU.* FROM TBL_LEGAL_DISPUTREGISTRATION TLD  LEFT JOIN TBL_CYHW_UNIT TCU ON TLD.CONTRACTINFO = TCU.CONTRACTID WHERE TLD.DISPUTEID = #{disputeId}")
    TblCyhwUnitMySql findContractByDisputeId(BigDecimal disputeId);

    @SelectProvider(type=TblLegalArbitratsettlementMySqlMapperSqlConfig.class,method="findListByPageInfo")
    List<TblLegalArbitratsettlementMySql> findListByPageInfo(PageInfo<TblLegalArbitratsettlementMySql> pageInfo, TblLegalArbitratsettlementMySql negotia,Integer disputeid);

    @SelectProvider(type=TblLegalArbitratsettlementMySqlMapperSqlConfig.class,method="findListByPageInfoCount")
    Integer findListByPageInfoCount(TblLegalArbitratsettlementMySql negotia,Integer disputeid);

    @InsertProvider(type = TblLegalArbitratsettlementMySqlMapperSqlConfig.class, method = "saveDiputergistration")
    @Options(useGeneratedKeys=true, keyProperty="arbitraid", keyColumn="ARBITRAID")
    void saveDiputergistration(TblLegalArbitratsettlementMySql arbitrat);

    @Delete("DELETE FROM TBL_LEGAL_ARBITRATSETTLEMENT WHERE ARBITRAID = #{arbitrat}")
    void removeLegalNegotiatedSettlemen(Integer arbitrat);

    @UpdateProvider(type=TblLegalArbitratsettlementMySqlMapperSqlConfig.class,method="modifyNegotiatedSettlement")
    @Options(useGeneratedKeys=true, keyProperty="arbitraid", keyColumn="ARBITRAID")
    void modifyNegotiatedSettlement(TblLegalArbitratsettlementMySql oldArbitrat);

    @Select("SELECT * FROM TBL_LEGAL_ARBITRATSETTLEMENT TLA\n" +
            "LEFT JOIN TBL_LEGAL_NEGOTIATEDSETTLEMEN TLN ON TLA.NEGOTIATEINFO = TLN.NEGOTIAID\n" +
            "LEFT JOIN TBL_LEGAL_DISPUTREGISTRATION TLD ON TLN.DISPUINFO = TLD.DISPUTEID\n" +
            "WHERE ARBITRAID = #{arbitraId}")
    TblLegalArbitratsettlementMySql findByarbitraid(Integer arbitraId);
}
